#region Summary

// 
// Owner : JackieHan 
// 
// Solution : Skomart.Spider 
// 
// Project : Jackie.Utility
// 
// File : ConversionConfigurationManager.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : 管理转换的配置信息
// 
// History : 
//			2010-10-09 10:38:37	    Create 
// 

#endregion

#region Using

using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Xml;
using Jackie.Utility.Spring;

#endregion

namespace Jackie.Utility.BvConversion
{
    /// <summary> 
    /// 管理转换的配置信息
    /// </summary>
    public class ConversionConfigurationManager
    {
        private ConversionConfigurationManager()
        {

        }

        private static ConversionConfigurationManager manager;
        private static readonly object LockObj = new object();

        public static ConversionConfigurationManager Instance
        {
            get
            {
#if DEBUG
                manager = new ConversionConfigurationManager();
                if (SpringHelper.IsContainsObjectId("ConversionConfig"))
                {
                    var config = SpringHelper.GetObject<IConversionConfig>("ConversionConfig");
                    manager.BusinessObjectConfig = config.Config();
                }
                else
                {
                    var config = new DefaulteConversionConfig();
                    manager.BusinessObjectConfig = config.Config();
                }
#else

                if (manager == null)
                {
                    lock (LockObj)
                    {
                        if (manager == null)
                        {
                            manager = new ConversionConfigurationManager();
                            if (SpringHelper.IsContainsObjectId("ConversionConfig"))
                            { 
                                var config = SpringHelper.GetObject<IConversionConfig>("ConversionConfig");
                                manager.BusinessObjectConfig = config.Config();
                            }
                            else
                            {
                                var config = new DefaulteConversionConfig();
                                manager.BusinessObjectConfig = config.Config();
                            }
                        }
                    }
                }
#endif
                return manager;
            }
        }

        /// <summary>
        /// 一个Business配置可对应很多View
        /// </summary>
        public BusinessViewConfigCollection BusinessObjectConfig { get; private set; }
    }
}